package gold.digger;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC1072 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int maxEqualRowsAfterFlips(int[][] matrix) {
            Map<String, Integer> map = new LinkedHashMap<>();
            for (int[] line : matrix) {
                String key = getArrayKey(line);
                map.put(key, map.getOrDefault(key, 0) + 1);
            }
            TreeSet<Integer> set = new TreeSet<>();
            for (Integer count : map.values()) {
                set.add(count);
            }

            return set.last();
        }

        public String getArrayKey(int[] line) {
            if (line[0] == 1) {
                for (int i = 0; i < line.length; i++) {
                    line[i] = line[i] == 0 ? 1 : 0;
                }
            }
            return Arrays.toString(line);
        }
    }

    public void run() {
        Solution solution = new Solution();
        int[][] arr = InputUtil.toDoubleIntegerArray("[[0,0,0],[0,0,1],[1,1,0]]");
        System.out.println(solution.maxEqualRowsAfterFlips(arr));
    }

    public static void main(String[] args) throws Exception {
        LC1072 an = new LC1072();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
